package twoPointer;

import java.util.Scanner;

/**
 * Created by JiaJia on 2019/4/18 0018.
 */
public class TwoSum {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String[] input=sc.nextLine().split(",");
            int n=input.length;
            int[] array=new int[n];
            for (int i = 0; i <n ; i++) {
                array[i]=Integer.parseInt(input[i]);
            }
            int t=sc.nextInt();
            System.out.println(twoSum(array,t));
        }
        sc.close();
    }
    private static int[] twoSum(int[] array,int t){
        int[] result=new int[2];
        int i=0;
        int j=array.length-1;
        while (i<j){
            int sum=array[i]+array[j];
            if(sum==t){
                result[0]=array[i];
                result[1]=array[j];
                return result;
            }else if(sum<t){
                i++;
            }else {
                j--;
            }
        }
        return null;
    }
}